<template>
	<view>
		
		<u-toast ref="uToast" />
		
		<view class="text-input">
			<view class="left-text">
				<text>反馈:</text>
			</view>
			<view class="right-textarea">
				<textarea class="textarea" placeholder="输入反馈内容(30字)" maxlength="30" placeholder-class="textarea" v-model="feedback"></textarea>
			</view>
		</view>
		<view class="button">
			<view class="submit-button">
				<u-button type="primary" icon="edit-pen" text="提交" @click="saveFeedback()"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				feedback: ""
			}
		},
		methods: {
			saveFeedback() {
				let params = {
					"userId": uni.getStorageSync('userId'),
					"feedbackValue": this.feedback,
				}
				const _this = this
				uni.request({
					header: {
						  'Content-Type': 'application/json',
						  'token': uni.getStorageSync('token')
					   }, 
					url: this.$USER_AVATOR_URL.USER_AVATOR_URL+"/feedback/addfeedback",
					method: 'POST',
					data: params,
					success(res) {
						if(res.data.code == 200){
							_this.$refs.uToast.show({
								type: 'success',
								title: '添加成功',
								message: res.data.errorMessage,
								duration: 700,
								complete() {
									uni.switchTab({
										url: '/pages/personal/personal',
										success: (res) => {
											let page = getCurrentPages().pop();
											if (page == undefined || page == null) return;
											page.onLoad();
										}
										
									})
								},
							})
						}else {
							_this.$refs.uToast.show({
								type: 'error',
								title: '添加失败',
								message: res.data.errorMessage,
								duration: 1000
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
	.text-input{
		display: flex;
		flex-wrap: wrap;
		margin-top: 100rpx;
		margin-left: 30rpx;
	}
	.left-text{
		width: 100rpx;
		font-size: 40rpx;
		color: #303133;
		display: flex;
		align-items: flex-start;
	}
	.right-textarea{
		width: 550rpx;
		display: flex;
		align-items: flex-start;
	}
	.textarea{
		font-size: 40rpx;
		height: 170rpx;
		
		border-style: solid;
		border-color: #8a8a8a;
		border-radius: 12rpx;
	}
	.button{
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 100rpx;
	}
	.submit-button{
		width: 400rpx;
		height: 100rpx;
		font-size: 40rpx;
	}
</style>
